

import { Entity, PrimaryGeneratedColumn, JoinTable, Column, OneToOne, ManyToMany } from 'typeorm';
import { Hobby } from './Hobby.dao';
import { Exclude, Expose } from "class-transformer"
import { UserDetail } from './UserDetail.dao';

@Entity('user')
export class User {

  @PrimaryGeneratedColumn()
  id: number;

  @Column({ comment: '用户名' })
  username: string;

  @Exclude()
  @Column({ comment: '密码' })
  password: string;

  @Column({ comment: '昵称' })
  nikeName: string;

  @Column({ comment: '年龄' })
  age: number;

  // @Expose()
  // get fullInfo() {
  //   return `${this.username}--${this.age}`
  // }

  @OneToOne(() => UserDetail, detail => detail.user)
  userDetail: UserDetail


  @ManyToMany(() => Hobby, hobby => hobby.users)
  @JoinTable()
  hobbies: Hobby[]
}
